package com.multimedia.scala.euler

import scala.annotation.tailrec
import scala.collection.mutable.HashMap
object Asd174 {
    def main(args : Array[String]) : Unit = {
        var buf = new HashMap[Int, Int]().withDefaultValue(0)

        def go(nb: Int) {
            @tailrec
        	def next(t: Int, n: Int): Boolean = {
        	    if (t>1000000) false
        	    else {
        	        //println(t)
        	        buf(t) += 1 
        	        next(t + n, n + 8)
        	    }
        	}

        	next(4*nb, 4*nb + 8)
        }

        (2 to 250001).foreach(go)
        println((1 to 10).map(i=>buf.count(x=>{x._2==i})).sum)
    }
}
